﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lexer.SyntaxTree
{
    /// <summary>
    /// A class dealing with If statements and they're code paths.
    /// </summary>
    class IfSyntaxNode : SyntaxNode
    {
        private SyntaxNode ifTrue;
        private SyntaxNode ifFalse;
        private BinaryOperationSyntaxNode condition;
        public override SyntaxNode NextNode
        {
            get
            {
                return base.NextNode;
            }
            set
            {
                base.NextNode = value;
                if (this.ifTrue != null)
                    this.ifTrue.AddToEnd(value);
                else
                    this.ifFalse = value;
                if (ifFalse != null)
                    this.ifFalse.AddToEnd(value);
                else
                    this.ifFalse = value;
            }
        }
        public SyntaxNode IfTrue
        {
            get { return this.ifTrue; }
            set { this.ifTrue = value; }
        }
        public SyntaxNode IfFalse
        {
            get { return this.ifFalse; }
            set { this.ifFalse = value; }
        }
        public BinaryOperationSyntaxNode Condition
        {
            get { return this.condition; }
            set { this.condition = value; }
        }
        public override string ToString()
        {
            return "If: " + this.condition;
        }
    }
}
